﻿@model RH.Web.ViewModels.UtilityModels.ListConfig        
@using RH.Web.Utility;

@{
    //String test = ViewData[AppConstants.ViewDataKeys.SUB_MODEL] != null ? "a" : "b";
    //String ReqFrom = ViewData[AppConstants.ViewDataKeys.SUB_MODEL] == "Receive" ? "Receive" : "Issue";
    //bool _IsIssue = ViewData[AppConstants.ViewDataKeys.SUB_MODEL] == "Receive" ? false : true;
    //bool _IsIssue = ViewData[AppConstants.ViewDataKeys.SUB_MODEL];

    //bool _IsIssue = ViewData[AppConstants.ViewDataKeys.SUB_MODEL] != null ? true : false;
    bool _IsIssue = (ViewBag.RequestType == "Issue") ? true : false;
    bool _IsPosted = (ViewBag.IsPosted == "Yes") ? true : false;

    String pageTitle = "Manage Inventory";
    ViewBag.Title = Html.GetPageTitle(pageTitle);
}

@*@Html.Partial("_DataTableList", Model)*@

<div class="page-heading">
    <h1>@pageTitle</h1>
    <div>
        <text>Add or update product Receive or Issue details.</text>
    </div>
</div>

<div class="GroupBox">
    <div id="divSearchFilter">
        @if (_IsIssue)
        {
            <input type="radio" id="rdbReceive" value="Receive" name="Inventory"/><label for="rdbReceive">Receive</label>
            <input type="radio" id="rdbIssue" value="Issue"  checked="checked" name="Inventory"/><label for="rdbIssue">Issue</label>
        }
        else
        {
            <input type="radio" id="rdbReceive" value="Receive" checked="checked" name="Inventory"/><label for="rdbReceive">Receive</label>
            <input type="radio" id="rdbIssue" value="Issue"  name="Inventory"/><label for="rdbIssue">Issue</label>
        }
        @if (_IsPosted)
        {
            <input type="checkbox" id="chkPosted" checked="checked" value=""/><label for="chkPosted">Posted?</label>
        }
        else
        {
            <input type="checkbox" id="chkPosted" value=""/><label for="chkPosted">Posted?</label>
        }
        
    </div>
    <div id="divTransactionList"></div>
</div>

    
@*<script src="../../../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>*@
<script language="javascript" type="text/javascript">
    $(document).ready(function () {        
        $('#divSearchFilter input').click(function () {
            GetSearchResult();
        });
        GetSearchResult();
    });

    function GetSearchResult() { 
        ShowLoadingAnimation(false);
        var url = '/Private/Inventory/GetTransactionList';
        var data = 'type=';
        if ($('#rdbReceive').is(':checked'))
            data += 'Receive';
        else
            data += 'Issue'
        data += '&Posted='
        if($('#chkPosted').is(':checked'))
            data += '1';
        else
            data += '0';
        //var url = url + data;
        //alert(url + ' Data: ' + data);

        Ajax(url, data, function (result) {
            HideLoadingAnimation();
            $('#divTransactionList').html(result);
        });

    }
</script>



